package com.diana.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.diana.entity.ManagerMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author anzhi
 * @since 2019-04-21
 */
public interface ManagerMenuMapper extends BaseMapper<ManagerMenu> {

    @Select("SELECT a.*,(select menuName from manager_menu b where b.menuId=a.parentId) parentName," +
            "(SELECT GROUP_CONCAT(menuId) from manager_menu b where b.parentId = a.menuId)childIds FROM manager_menu" +
            " a where a.parentId = #{parentId} ${joinsql}")
    List<Map<String,Object>> getList(@Param("parentId") String parentId, @Param("joinsql") String joinsql);

    @Select("SELECT a.*,(select menuName from manager_menu b where b.menuId=a.parentId) parentName" +
          " FROM manager_menu a where a.menuId = #{menuId} and a.status !=2")
    Map<String,Object> getMenuInfo(@Param("menuId") String menuId);
}
